﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Castle.Windsor;
using Castle.Windsor.Installer;
using DAL;
using Service;

namespace ScheduleService
{
    public class BootstrapContainer
    {
        private static IWindsorContainer container;
        private static object lockwindsor = new object(); 
        public static void CreateContainer()
        {
            if (container == null)
            {
                Installer();
            }
        }
        public static IWindsorContainer Container
        {
            get
            {
                if (container == null)
                {
                    lock (lockwindsor)
                    {
                        if (container == null)
                        {
                            Installer();
                        }
                    }
                }
                return container;
            }
        }
        private static void Installer()
        {
            container = new WindsorContainer();
            container.Install(FromAssembly.This());
            container.Install(FromAssembly.Containing<DalInstaller>());
            container.Install(FromAssembly.Containing<ServiceInstaller>());
        }
    }
}
